local args = {...}

local function checksys(txt)
 if txt == "kernel" or txt == "gui" or txt == "app" or txt == "log" or txt == "config" or txt == "manual" or txt == "search" or txt == "tpm" or txt == "exception" or string.find(txt, "boot/") or string.find(txt, "system/") or string.find(txt, "/startup") then
  --gui.printAppWarning("kernel", "attempt to perform restricted operations")
  return true
 end
end

if #args < 1 or not fs.exists(shell.resolveProgram(args[1])) or fs.isDir(shell.resolve(args[1])) then
 gui.printAppInfo("config", "file not specified")
 return
end

if not checksys(shell.resolveProgram(args[1])) then
 if os.loadAPI(shell.resolveProgram(args[1])) then
  config.save(_G[args[1]], textutils.serialize(args[1]))
  os.unloadAPI(args[1])
  gui.printAppSuccess("config", "conversion succeeded")
 end
else
 exception.throw("RestrictedOpsException")
end